-- 缺水的掌握怒海
local queshuidezhangwonuhai = fk.CreateSkill{
    name = "mcdh_queshuidezhangwonuhai",
}

queshuidezhangwonuhai:addEffect(fk.TargetSpecified,{
    can_trigger = function(self, event, target, player, data)
        if target ~= player or not player:hasSkill(self) then
            return false
        end
        if player:getMark("mcdh_charge") < 2 then
            return false
        end
        if #AimGroup:getAllTargets(data.tos) ~= 1 then
            return false
        end
        return (data.from == player.id) ~= (data.to == player.id)
    end,
    on_cost = function(self, event, target, player, data)
        if player.room:askForSkillInvoke(player, self.name, nil, "#mcdh__QueShuiDeZhangWoNuHai-invoke:" .. data.from) then
            lib.mcdh_charge(player, -2)
            return true
        end
    end,
    on_use = function(self, event, target, player, data)
        local ids = player:drawCards(2, self.name)
        player:showCards(ids)
        for i = 1, #ids do
            local card = Fk:getCardById(ids[i])
            if card.type == Card.TypeBasic then
                if #player.room:askForDiscard(player, 1, 1, false, self.name, true, "jink", "#mcdh__QueShuiDeZhangWoNuHai-askdiscard:") == 0 then
                    lib.Damage(
                            {
                                from = nil,
                                to = player,
                                damage = 1,
                                skillName = self.name,
                            }
                    )
                end
                break
            end
        end
    end
})

queshuidezhangwonuhai:addEffect(fk.TargetConfirmed,{
    can_trigger = function(self, event, target, player, data)
        if target ~= player or not player:hasSkill(self) then
            return false
        end
        if player:getMark("mcdh_charge") < 2 then
            return false
        end
        if #AimGroup:getAllTargets(data.tos) ~= 1 then
            return false
        end
        return (data.from == player.id) ~= (data.to == player.id)
    end,
    on_cost = function(self, event, target, player, data)
        if player.room:askForSkillInvoke(player, self.name, nil, "#mcdh__QueShuiDeZhangWoNuHai-invoke:" .. data.from) then
            lib.mcdh_charge(player, -2)
            return true
        end
    end,
    on_use = function(self, event, target, player, data)
        local ids = player:drawCards(2, self.name)
        player:showCards(ids)
        for i = 1, #ids do
            local card = Fk:getCardById(ids[i])
            if card.type == Card.TypeBasic then
                if #player.room:askForDiscard(player, 1, 1, false, self.name, true, "jink", "#mcdh__QueShuiDeZhangWoNuHai-askdiscard:") == 0 then
                    lib.Damage(
                            {
                                from = nil,
                                to = player,
                                damage = 1,
                                skillName = self.name,
                            }
                    )
                end
                break
            end
        end
    end
})

return queshuidezhangwonuhai

